/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/12/03
*/
#include "LuaHorizontalLayout.h"
#include "../../utilities/Log.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

#define CObjPtr (HorizontalLayout::ToHorizontalLayout(m_cobj))

void* LuaHorizontalLayout::GetInterface(void* data)
{
    if (!data) return 0;
    LuaHorizontalLayout* horizontalLayout = new LuaHorizontalLayout((HorizontalLayout*)data);
#ifdef EDUI_TEST_NEW_DELETE
    ++m_newdeleteNum;
    Log("[LuaHorizontalLayout] new LuaHorizontalLayout : %d, %d", horizontalLayout, data);
#endif
    return horizontalLayout;
}

void LuaHorizontalLayout::Release()
{
#ifdef EDUI_TEST_NEW_DELETE
    --m_newdeleteNum;
    Log("[LuaHorizontalLayout] delete LuaHorizontalLayout : %d, %d, %s", this, m_cobj, this->GetName());
#endif
    delete this;
}

LuaHorizontalLayout::LuaHorizontalLayout(HorizontalLayout* horizontalLayout) : LuaContainer(horizontalLayout)
{}

LuaHorizontalLayout::~LuaHorizontalLayout()
{}

//----------------------------------------//

bool LuaHorizontalLayout::IsCenter()
{
    return CObjPtr->IsCenter();
}

void LuaHorizontalLayout::SetCenter(bool bCenter)
{
    CObjPtr->SetCenter(bCenter);
}
//----------------------------------------//

void LuaHorizontalLayout::Register(LuaState *L)
{
    LuaObject obj = LuaHelperNS::AddToMetas(L, "HorizontalLayout", "Container");
    obj.SetObject("__index", obj);
    obj.RegisterDirect("__NewCObj__", &LuaHorizontalLayout::GetInterface);

    obj.RegisterObjectDirect("IsCenter", (LuaHorizontalLayout*)0, &LuaHorizontalLayout::IsCenter);
    obj.RegisterObjectDirect("SetCenter", (LuaHorizontalLayout*)0, &LuaHorizontalLayout::SetCenter);
}

#undef CObjPtr

EDUI_NAMESPACE_END

#endif